<div id="content">
	<div class="row s_page_title">
		<sa-big-breadcrumbs [items]="['系统基础管理','用户管理']" icon="fa fa-list" class="col-xs-12 col-sm-7 col-md-7 col-lg-4"></sa-big-breadcrumbs>
	</div>
	<sa-widgets-grid>
		<div class="s_table">
			<div sa-widget [editbutton]="false" color="darken" class="clearfix">
				<header><span class="widget-icon"> <i class="fa fa-table"></i> </span><h2>用户管理</h2></header>
				<div>
					<div class="widget-body no-padding">
						<div class="page-header clearfix s_table_opreation">
							<div class="left page-header-btn">
								<div class="top_module top_module_box">
									<span class="top_module_label module_text">用户类型</span>
									<select name="" class="top_module_select" [(ngModel)]="userType" (change)='table_search()'>
										<option value="">全部</option>
										<option *ngFor="let item of userTypeList" [value]='item.id'>{{item.text}}</option>
									</select>
								</div>
								<div class="top_module">
									<span class="top_module_label module_text">员工类型</span>
									<select name="" class="top_module_select" [(ngModel)]="workerType">
										<option value="">全部</option>
										<option value="0">管理者</option>
										<option value="1">正式员工</option>
										<option value="2">兼职员工</option>
										<option value="3">外包员工</option>
									</select>
								</div>
								<button class="btn btn-primary" (click)="table_search()">查询</button>
								<button  type="button"  class="btn btn-primary" (click)="new_user()" *ngIf="userAdd">添加</button>
							</div>
							<div class="right top-search">
								<input type="text" [(ngModel)]="searchKey" (change)="table_search()" class="search-input" placeholder="姓名、账户名称...">
								<span class="top-search-box">
							        <button class="top-search-btn" type="button" (click)="table_search()"> <i class="fa fa-search"></i></button>
							    </span>
							</div>
						</div>
						<div class="table_scroll">
							<table class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
								<thead>
									<tr>
										<th>账户名</th>
										<th>姓名</th>
										<th>用户类型</th>
										<th>所属角色</th>
										<th>电话号码</th>
										<th>用户描述</th>
										<th>单位名称</th>
										<th>实施团队</th>
										<th>员工类型</th>
										<th>创建者</th>
										<th>创建时间</th>
										<th>到期时间</th>
										<th>在职状态</th>
										<th>是否锁定</th>
										<th>锁定登录权限</th>
										<th *ngIf="userEdit||userDeleteBatch||userResetPassword">操作</th>
										<th>权限分配</th>
									</tr>
								</thead>
								<tbody>
									<tr *ngFor="let row of tableData" >
										<td>{{row.userName}}</td>
										<td>{{row.name}}</td>
										<td>{{row.userTypeName}}</td>
										<td>{{row.role.name}}</td>
										<td>{{row.phone}}</td>
										<td>{{row.description}}</td>
										<td>{{row.companyName}}</td>
										<td>{{row.outsourcingTeamName}}</td>
										<td>
											<span *ngIf="row.workerType == '0'">管理者</span>
											<span *ngIf="row.workerType == '1'">正式员工</span>
											<span *ngIf="row.workerType == '2'">兼职员工</span>
											<span *ngIf="row.workerType == '3'">外包员工</span>
										</td>
										<td>{{row.createUserName}}</td>
										<td>{{row.createTime}}</td>
										<td>{{row.serviceEndTimeValue}}</td>
										<td>
											<span *ngIf="row.workerState == '1'" class="green">在职</span>
											<span *ngIf="row.workerState == '0'" class="red">离职</span>
										</td>
										<td>
										 	<span *ngIf="row.locked === 0" class="green">正常</span>
											<span *ngIf="row.locked === 1" class="red">web锁定</span>
											<span *ngIf="row.locked === 2" class="red">API锁定</span>
											<span *ngIf="row.locked === 3" class="red">全部锁定</span>
										</td>
										<td>
											<div *ngIf="row.locked === 0"><span class="web-border" (click)='isLocked("N",row,"WEB","1")'>WEB</span><span class="web-border" (click)='isLocked("N",row,"API","2")'>API</span></div>
											<div *ngIf="row.locked === 1"><span class="web-border bg-red" (click)='isLocked("Y",row,"WEB","0")'>WEB</span><span class="web-border" (click)='isLocked("N",row,"API","3")'>API</span></div>
											<div *ngIf="row.locked === 2"><span class="web-border" (click)='isLocked("N",row,"WEB","3")'>WEB</span><span class="web-border bg-red" (click)='isLocked("Y",row,"API","0")'>API</span></div>
											<div *ngIf="row.locked === 3"><span class="web-border bg-red" (click)='isLocked("Y",row,"WEB","2")'>WEB</span><span class="web-border bg-red" (click)='isLocked("Y",row,"API","1")'>API</span></div>
										</td>
										<td *ngIf="userEdit||userDeleteBatch||userResetPassword">
											<button type="button" (click)="updata_user(row.id)" *ngIf="userEdit"> 编辑</button>
											<button type="button" (click)="del_user(row)" *ngIf="userDeleteBatch">删除</button>
											<button type="button" (click)="reset_password(row)" *ngIf="userResetPassword">密码重置</button>
										</td>
										<td>
											<button type="button" (click)="menu_access(row)">菜单</button>
											<button type="button" (click)="car_access(row)">车辆</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="table-fix clearfix">
							<paginator [totalRecords]="totalCount"
						           [rows]="pageSize"
						           [currentPage]="curPage - 1"
						           (onPageChange)="paginate($event)">
							</paginator>
							<button type="button" class="btn default refresh_btn" (click)="refresh()"><i class="fa fa-refresh"></i></button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</sa-widgets-grid>
</div>